package org.ChrisRiffleSoftware.WhatIfJesusIsGod.ChuckNorrisJoker;

import android.graphics.drawable.Drawable;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * ChuckViewController
 * 
 * @author RIF
 * 
 */
public class ChuckViewController {

	// *************************************************************************
	// *************************************************************************
	// 					members
	// *************************************************************************
	// *************************************************************************

	private LinearLayout linLayout;

	private Button submitButton;

	private TextView jokeTxtView;

	private ChuckNorrisJokerActivity activity;
	
	private ImageView norisPicView;
	
	private CheckBox soundOnCheckBox;

	// *************************************************************************
	// *************************************************************************
	// 								constructors
	// *************************************************************************
	// *************************************************************************

	public ChuckViewController(ChuckNorrisJokerActivity pActivity) {
		activity = pActivity;
	}
	
	// *************************************************************************
	// *************************************************************************
	// 								methods
	// *************************************************************************
	// *************************************************************************
	
	/**
	 * getSoundOnCheckBox
	 */
	public CheckBox getSoundOnCheckBox(){
		if(soundOnCheckBox == null){;
			soundOnCheckBox = new CheckBox(activity);
			soundOnCheckBox.setText("Sound");
		}
		return soundOnCheckBox;
	}

	/**
	 * getViewLayout
	 * 
	 * @return
	 */
	LinearLayout getViewLayout() {
		if (linLayout == null) {
			linLayout = new LinearLayout(activity);
			linLayout.setOrientation(LinearLayout.VERTICAL);
			linLayout.addView(getNorisPicView());
			linLayout.addView(getSubmitButton());
			linLayout.addView(getSoundOnCheckBox());
			linLayout.addView(getJokeTxtView());
		}
		return linLayout;
	}

	
	
	/**
	 * getNorisPicView
	 * @return
	 */
	private ImageView getNorisPicView() {
		if (norisPicView == null) {

			Drawable d = activity.getResources().getDrawable(
					R.drawable.chuck_norris_215x184png);
			norisPicView = new ImageView(activity);
			norisPicView.setImageDrawable(d);
		}
		return norisPicView;
	}

	/**
	 * getSubmitButton
	 * 
	 * @return
	 */
	Button getSubmitButton() {
		if (submitButton == null) {
			submitButton = new Button(activity);
			submitButton.setText("DANGER");
			submitButton.setOnClickListener(activity);
		}
		return submitButton;
	}

	/**
	 * getJokeTxtView
	 * 
	 * @return
	 */
	TextView getJokeTxtView() {
		if (jokeTxtView == null) {
			jokeTxtView = new TextView(activity);
		}
		return jokeTxtView;
	}

}



